<#--空格处理-->
<#function space param>
    <#if param?length gt 15><#return ""/>
    <#else>
        <#return "               "?substring(param?length)/>
    </#if>
</#function>

<#-- operation 2 sql -->
<#function operation2Sql param>
    <#if param?starts_with("insert")><#return "insert"/></#if>
    <#if param?starts_with("update")><#return "update"/></#if>
    <#if param?starts_with("delete")><#return "delete"/></#if>
    <#return "select"/>
</#function>

<#-- mapperxml result -->
<#function mapperResult operation>
    <#if operation.resultmap??><#return 'resultMap="${operation.resultmap}"'/></#if>
    <#if operation.resulttype??><#return 'resultType="${operation.resulttype}"'/></#if>
    <#if operation.name?starts_with("insert")><#return ''/></#if>
    <#if operation.name?starts_with("update")><#return ''/></#if>
    <#if operation.name?starts_with("delete")><#return ''/></#if>
    <#return 'resultMap="BaseResultMap"'/>
</#function>

<#function timeout operation>
    <#if operation.timeout??><#return ' timeout="${operation.timeout}"'/></#if>
    <#return ""/>
</#function>

<#-- insert  时字段处理 -->
<#function insertVal column>
	<#if column.sqlName == "DELETE_FLAG">
        <#return 0>
    </#if>
    <#if column.sqlName == "CREATED_DATE">
        <#return 'NOW()'>
    </#if>
    <#if column.sqlName == "UPDATED_DATE">
        <#return 'NOW()'>
    </#if>
    <#return '${"#"}{${column.javaName}}'/>
</#function>

<#-- Update 时字段处理 -->
<#function updateVal column>
    <#return '${"#"}{${column.javaName}}'/>
</#function>

<#-- update 中需要设置的字段 -->
<#function updateIncludeColumn column primaryKeys>
	<#if column.sqlName == "CREATED_BY" || column.sqlName == "CREATED_DATE" 
	  || column.sqlName == "UPDATED_DATE" || column.sqlName == "DELETE_FLAG"  >
        <#return false>
    </#if>
    <#list primaryKeys as pkcolumn>
        <#if pkcolumn.sqlName == column.sqlName><#return false></#if>
    </#list>
    <#return true>
</#function>

<#-- query 中需要设置的字段 -->
<#function queryIncludeColumn column primaryKeys>
    <#list primaryKeys as pkcolumn>
        <#if pkcolumn.sqlName == column.sqlName><#return false></#if>
    </#list>
    <#if column.sqlName == "CREATED_DATE"><#return false></#if>
    <#if column.sqlName == "CREATEBY"><#return false></#if>
    <#if column.sqlName == "DELETE_FLAG"><#return false></#if>
    <#if column.sqlName == "UPDATED_DATE"><#return false></#if>
    <#if column.sqlName == "UPDATEBY"><#return false></#if>
    <#return true>
</#function>

<#-- query 中需要设置的字段 -->
<#function checkHaveDeleteFlag columns>
    <#list columns as column>
        <#if column.sqlName == "DELETE_FLAG"><#return true></#if>
    </#list>
    <#return false>
</#function>
